﻿using System;
using MvcFlow.Mvc;
using NUnit.Framework;

namespace MvcFlow.Tests.Mvc
{
    [TestFixture]
    public class UrlTests
    {
        [Test]
        public void UrlParsingShouldWork()
        {
            var url = new Url(new Uri("http://www.google.com?q=10&hello=world"));

            Assert.AreEqual("world",url.QueryString["Hello"]);
            Assert.AreEqual("10",url.QueryString["q"]);
        }

        [Test]
        public void UrlPathSegmentsShouldBeFilled()
        {
            var url = new Url(new Uri("http://www.google.com/test/p"));

            Assert.AreEqual(2,url.PathSegments.Length);
            Assert.AreEqual("test",url.PathSegments[0]);
            Assert.AreEqual("p",url.PathSegments[1]);
        }

        [Test]
        public void UrlValueShouldBePreserved()
        {
            var url = new Url(new Uri("http://www.google.com/test"));

            Assert.AreEqual("http://www.google.com/test",url.Value);
        }
    }
}